﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Ryder_US_Website.BUS;
using Ryder_US_Website.Utils;

namespace Ryder_US_Website.Presentation.Admin
{
    public partial class Customer_Insert : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["RUS_User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void btnHuy_Click(object sender, EventArgs e)
        {
            Response.Redirect("Customer_List.aspx");
        }
        protected void clean()
        {
            txtTenKhachHang.Text = "";
            txtTenDangNhap.Text = "";
            txtMatKhau.Text = "";
            txtDienThoai.Text = "";
            txtDiaChi.Text = "";
            txtKhoanNo.Text = "";
            txtTaiKhoan.Text = "";
            
        }
        protected void btnLamLai_Click(object sender, EventArgs e)
        {
            clean();
        }
        protected void btnThem_Click(object sender, EventArgs e)
        {
            RUS_Customer cus = new RUS_Customer();
            cus.Customer_name = txtTenKhachHang.Text;
            cus.Customer_username = txtTenDangNhap.Text;
            cus.Customer_password = txtMatKhau.Text;
            cus.Customer_doubt = decimal.Parse(txtKhoanNo.Text);
            cus.Customer_address = txtDiaChi.Text;
            cus.Customer_phone = txtDienThoai.Text;
            cus.Customer_banking = txtTaiKhoan.Text;
            cus.Customer_trash = 0;
            try
            {
                CustomerBUS.Insert(cus.Customer_name, cus.Customer_username, cus.Customer_password, cus.Customer_address, cus.Customer_phone, cus.Customer_doubt, cus.Customer_banking);
                Response.Write(UtilHelpers.ShowMessage("Thêm thành công"));
                Response.Redirect("Customer_List.aspx");

            }
            catch (Exception ex)
            {
                Response.Write(UtilHelpers.ShowMessage(ex.Message));
            }
            
        }
    }
}
